package com.lp.service.impl;



import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lp.bean.IotVideoInfo;
import com.lp.bo.IotVideoInfoBO;
import com.lp.cache.CacheName;
import com.lp.cache.ProCacheUtil;
import com.lp.common.Code;
import com.lp.common.Constants;
import com.lp.ezuiz.EzuizService;
import com.lp.service.IotVideoInfoService; 
 
@Service
public class IotVideoInfoServiceImpl extends BaseServiceImpl implements IotVideoInfoService {
	
	@Autowired
	private EzuizService ezuizService;

	@Override
	public Map<String, Object> deleteVideo(IotVideoInfoBO obj) {
		Map<String, Object> resultMap = getResultMap();
		try {
			// 需要先查询，然后删除
			obj = dao.selectOne("IotVideoInfo.selectOne", obj) ;
			//以删除所有项目中的当前设备
			IotVideoInfo video = new IotVideoInfo();
			video.setDevice_serial(obj.getDevice_serial());
			resultMap = ezuizService.deleteDevice(video);
			if( isOk(resultMap) ){
				obj.setDelete_flag( Constants.DELETE.YES );
				Integer row = dao.update("IotVideoInfo.update", obj);
				if(row > 0){
					ProCacheUtil.removeCache(CacheName.VIDEO_INFO,  obj.getDevice_serial() );
				}
			}
		} catch (Exception e) {
			e.printStackTrace();
			putStatusCode(resultMap, Code.ResponseCode.SystemCode.ERROR);
		}
		return resultMap;
	} 
 
 
 
} 
 
 
